﻿@using RuoVea.ExDto
@using RuoVea.OmiArticle.Attributes
@using RuoVea.OmiArticle
@using RuoVea.OmiArticle.Language
@using RuoVea.OmiArticle.Options
@{
    Layout = "";
    AppConfig config = ConfigManages.Config ?? new AppConfig();
}
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@Html.Raw(i18n.tag_management)</title>
   <link href="~/ruoveaui/xg6rvft8p/avue/index.css" rel="stylesheet" />
    <link href="~/ruoveaui/xg6rvft8p/elementui/index.min.css" rel="stylesheet" />
    <style> .el-button [class*="el-icon-"] + span { margin-left: 1px !important; } </style>
</head>
<body>
    <div id="app" v-cloak>
        <avue-crud :data="tableData" :option="option" :page.sync="pageOption" :table-loading="loading"
                   v-on:refresh-change="refreshChange"
                   v-on:row-save="handleRowSave"
                   v-on:row-update="handleRowUpdate"
                   v-on:row-del="handleRowDel"
                   v-on:search-change="searchChange"
                   v-on:search-reset="resetChange"
                   :cell-style="cellStyle"
                   v-on:on-load="onLoad">
            <template slot="avatar" slot-scope="scope">
                <el-avatar shape="circle" :src="scope.row.avatar">{{scope.row.account}} </el-avatar>
            </template>
            <template slot="record" slot-scope="scope">
                <modify-record :data="scope.row"></modify-record>
            </template>

        </avue-crud>
    </div>
    <script src="~/ruoveaui/xg6rvft8p/vue/vue.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.i18n.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.lang.js"></script>
    <script>
        Vue.prototype.i18n.messages.zhCN = { ...Vue.prototype.i18n.messages.zhCN, ...{  "name": "名称","categ ory": "所属分类","property_v alue": "属性值","dictionary_v alue": "字典值","is_default": "是否默认", "Display Text": "显示文本", "Tag Type": "标签类型", "Style (Style)": "样式(Style)", "Style (Class)": "样式(Class)", "Extended  Data": "拓展数据"} };
        Vue.prototype.i18n.messages.en = { ...Vue.prototype.i18n.messages.en, ...{ "name": "Name","category": "Belongs  to Category","property_value": "Pr operty Value","dictionary_value": "Dict ionary Value","is_default":  "Is Default","Display Text": "Display Text", "Tag Type": "Tag Type", "Style (Style)": "Style (Style)", "Style (Class)": "Style (Class)", "Extended Data": " Extended Data"} };
        Vue.prototype.i18n.messages.fr = { ...Vue.prototype.i18n.messages.fr, ...{ "name": "Nom","category": "Catégor ie associée","property_value": "Valeur d e propriété","dictionary_value": "Valeur de d ictionnaire","is_default":  "Par défaut","Display Text": "Texte affiché", "Tag Type": "Type de balise", "Style (Style)": "Style (Style)", "Style (Class)": "Style (Class)", "Extended Data": "Donn ées étendues"} };
        Vue.prototype.i18n.messages.ja = { ...Vue.prototype.i18n.messages.ja, ...{ "name": "名称","category ": "所属カテゴリ","property_value": "プロパティ値", "dictionary_va lue": "辞書値","is_default":  "デフォルトかどうか","Display Text": "表示テキスト", "Tag Type": "タグの種類", "Style (Style)": "スタイル（Style）", "Style (Class)": "スタイル（Class）", "Extended Da ta": "拡張データ"} };
        Vue.prototype.i18n.messages.vi = { ...Vue.prototype.i18n.messages.vi, ...{ "name": "Tên","category": "Phân loại thuộc về","property_value": "Giá trị thuộc tính","dictionary_value": "Giá trị từ điển","is_default": "Có phải mặc định không","Display Text": "Văn bản hiển thị", "Tag Type": "Loại thẻ", "Style (Style)": "Kiểu (Style)", "Style (Class)": "Kiểu (Class)", "Extended Data": "Dữ liệu mở rộng"} };
        Vue.prototype.i18n.messages.zhTW = { ...Vue.prototype.i18n.messages.zhTW, ...{ "name": "名稱","catego ry": "所属分类","property_va lue": "属性值","dictionary_va lue": "字典值","is_default": "是否默认", "Display Text": "顯示文本", "Tag Type": "標籤類型", "Style (Style)": "樣式(Style)", "Style (Class)": "樣式(Class)", "Extended D ata": "擴展數據"} };
     </script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/index.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/zhCN.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/en.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/fr.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/ja.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/vi.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/elementui/lang/zhTW.js"></script>
    <script>Vue.prototype.$baseURL = "@config?.PrefixRoute";</script>
    <script src="~/ruoveaui/xg6rvft8p/vue/axios.min.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/vue/vue-i18n.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/avue/avue.min.js"></script>
    <script src="~/ruoveaui/xg6rvft8p/avue/avue.min.option.js"></script>
    <script>
        var tagTypeData = [{ label: `primary`, value: `primary`, }, { label: `success`, value: `success`, },{ label: `info`, value: `info`, },{ label: `warning`, value: `warning`,},{ label: `danger`, value: `danger`, }];
        new Vue({
            el: '#app',
            data() {
                return {

                    name: "tag",
                    pageUrl: "/tag/pages",
                    addUrl: "/tag/add",
                    editUrl: "/tag/update",
                    deleteUrl: "/tag/delete",
                    pageOption: {
                        total: 0,
                        page: 1,
                        pageSize: 10
                    },

                    loading: true,
                    btnLoading: false,
                    tableData: [],
                    searchParams: {},

                    option: {
                        searchShowBtn: Permissions.avePermission(`tag:pages`),
                        refreshBtn: Permissions.avePermission(`tag:pages`),
                        addBtn: Permissions.avePermission(`tag:addData`),
                        editBtn: Permissions.avePermission(`tag:updateData`),
                        delBtn: Permissions.avePermission(`tag:deleteData`),
                        viewBtn: Permissions.avePermission(`tag:data`),
                        rowKey: 'id',
                        searchShow: false,
                        dialogWidth: "600",
                        column: [
                            { prop: "id", label: `${this.i18n.t('primary_key')}`, search: false, hide: true, type: "number", display: false, showColumn: false, },
            
                            { prop: "name", label:  `${this.i18n.t('name')}`, search: true, hide: false, type: "input", clearable: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            { prop: "code", label: `${this.i18n.t('code')}`, search: true, hide: false, type: "input", clearable: true, rules: [{ required: true, trigger: "blur", message: `${this.i18n.t('pleaseenter')}` }], },
                            { prop: "sort", label: `${this.i18n.t('sort')}`, search: false, hide: false, type: "number", step: 100, value: 100, clearable: true },
                            { prop: "remark", label: `${this.i18n.t('note')}`, type: 'textarea', hide: true, showColumn: false, span: 24, rows: 2, },
                            { prop: "record", label: `${this.i18n.t('modification_record')}`, slot: true, display: false, showColumn: false, minWidth: 140, },
                        ]
                    }
                }
            },
            created() {
            },
            methods: {
                cellStyle({ row, column, rowIndex, columnIndex }) {
                    
                },
                hasPermission(key) {
                    if (key === 'columnBtn' || key === 'menu' || key === 'refreshBtn') return true;
                    else return Permissions.avePermission(`${this.name}:${key}`);
                },
                onLoad(page, done) {
                    var data = { ...page, ...this.searchParams , ...{ TypeId: this.TypeId }};
                    this.$http.post(`${this.pageUrl}`, data).then((res) => {
                        this.tableData = res.rows;
                        this.pageOption.total = res.totalRows;
                        this.loading = false;
                        if (done) { done(); }
                    }).catch(e => {
                        this.loading = false;
                        console.log(e);
                    });
                },
                searchChange(params, done) {
                    this.searchParams = params;
                    this.pageOption.page = 1;
                    this.onLoad(this.pageOption, done);
                },
                resetChange(item) {
                    this.searchParams = item;
                    this.pageOption.page = 1;
                    this.onLoad(this.pageOption);
                },
                refreshChange() { this.onLoad(this.pageOption); },
                handleRowSave(form, done, loading) {
                    form.confirm = form.password;
                    this.$http.post(`${this.addUrl}`, form).then((res) => {
                        loading();
                        if (res == true) {
                            this.$message({ message: `${this.i18n.t('submit_success')}`, center: true, type: 'success' });
                            done(form);
                            this.pageOption.page = 1;
                            this.onLoad(this.pageOption);
                        }
                    }).catch(e => {
                        loading();
                    });
                },
                handleRowUpdate(row, index, done, loading) {
                    this.$http.post(`${this.editUrl}`, row).then((res) => {
                        loading();
                        if (res == true) {
                            this.$message({ message: `${this.i18n.t('submit_success')}`, center: true, type: 'success' });
                            done(row);
                        }
                    }).catch(e => {
                        loading();
                    });
                },
                handleRowDel(form, index, done) {
                    this.$confirm(this.i18n.t('confirmdelete'), this.i18n.t('tips'), { confirmButtonText: this.i18n.t('determine'), cancelButtonText: this.i18n.t('cancel'), type: 'warning', customClass: "elmessagebox" }).then(() => {
                        let data = { id: form.id };
                        this.$http.delete(`${this.deleteUrl}`, { data, headers: { 'Content-Type': 'application/json' } }).then((res) => {
                            if (res == true) {
                                this.$message({ message: `${this.i18n.t('submit_success')}`, center: true, type: 'success' });
                                done(form)
                            }
                        });
                    }).catch(_ => { loading(); console.info(_); })
                }
            }
        });
    </script>
</body>
</html>